﻿@{
    ViewData["Title"] = "登录";
}
    <div class="login-wrapper">
        <div class="login-header">
        </div>
        <div class="login-body">
            <div class="layui-card">
                <div class="layui-card-header">
                    <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
                </div>
                <form class="layui-card-body layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                        <div class="layui-input-block">
                            <input name="userName" type="text" placeholder="账号" class="layui-input"
                                   lay-verType="tips" style="height:38px;" lay-verify="required" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                        <div class="layui-input-block">
                            <input name="pwd" type="password" placeholder="密码" class="layui-input"
                                   lay-verType="tips" style="height:38px;" lay-verify="required" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

<script>
        layui.use(['layer', 'form'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;

            // 表单提交
            form.on('submit(login-submit)', function (obj) {
                $.ajax({
                    url: '/api/system/login',
                    method: 'Post',
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(obj.field),
                    dataType: "JSON",
                    success: function (res) {
                debugger;
                        if (res.success) {
                            layer.msg(res.message, { icon: 1 }, function () {
                                window.location.href = '/home/index';
                            });
                        } else {
                            layer.closeAll('loading');
                            layer.msg(res.message, { icon: 5 });
                        }
                    }
                });
                return false;
            });
        });

</script> 
